<?php

namespace common\modules\user;

use yii\base\BootstrapInterface;

/**
 * Users module bootstrap class.
 */
class Bootstrap implements BootstrapInterface
{
    /**
     * @inheritdoc
     */
    public function bootstrap($app)
    {
        // Add module URL rules.
        $app->urlManager->addRules(
            [
                '<_a:(login|signup|activation|recovery|recovery-confirmation|resend|fileapi-upload)>' => 'user/guest/<_a>',
                '<_a:logout>'                                                                         => 'user/user/<_a>',
                '<_a:email>'                                                                          => 'user/default/<_a>',
                'my/settings/<_a:[\w\-]+>'                                                            => 'user/user/<_a>',
            ],
            false
        );

        $category = Module::categoryName('users');
        $app->i18n->translations[$category] = [
            'class'            => 'yii\i18n\PhpMessageSource',
            'basePath'         => '@backend/modules/user/messages',
            'forceTranslation' => true,
            'fileMap'          => [
                $category => 'user.php',
            ],
        ];
    }
}
